Imports DotNetNuke.UI.WebControls
Imports DotNetNuke.UI.Utilities

Public Class ClientEvents
    Inherits System.Web.UI.Page

    Protected Overrides Sub OnInit(ByVal e As System.EventArgs)
        MyBase.OnInit(e)
        DotNetNuke.UI.Utilities.ClientAPI.HandleClientAPICallbackEvent(Me)
    End Sub

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        MSAJAX.RegisterClientScript(Me.Page, "~/Samples/ClientEvents.aspx.js")
        If ClientAPI.IsInCallback(Me.Page) = False Then
            Dim oXML As System.Xml.XmlDocument = New System.Xml.XmlDocument
            oXML.Load(Server.MapPath(ResolveUrl("~/xml/FileMenu.xml")))
            Me.DNNMenu.LoadXml(oXML.OuterXml)
            Me.DNNTree.LoadXml(oXML.OuterXml)

            DotNetNuke.UI.Utilities.ClientAPI.RegisterClientVariable(Me.Page, "PageNS", tsControls.NamingContainer.ClientID & "_", True)
        End If

        Me.DNNToolBar.RegisterToolBar(lblToolBar, "onmouseover", "onmouseout", "null")
    End Sub

    Private Sub DNNMenu_PopulateOnDemand(ByVal source As Object, ByVal e As DNNMenuEventArgs) Handles DNNMenu.PopulateOnDemand
        AddPODNodes(e.Node)
    End Sub

    Private Sub DNNTree_PopulateOnDemand(ByVal source As Object, ByVal e As DNNTreeEventArgs) Handles DNNTree.PopulateOnDemand
        AddPODNodes(e.Node)
    End Sub

    Private Sub DNNTextSuggest_PopulateOnDemand(ByVal source As Object, ByVal e As DotNetNuke.UI.WebControls.DNNTextSuggestEventArgs) Handles DNNTextSuggest.PopulateOnDemand
        DataServices.PopulateList(e.Nodes, e.Text, DNNTextSuggest.MaxSuggestRows, DNNTextSuggest.CaseSensitive)
    End Sub


    Private Sub AddPODNodes(ByVal parent As DNNNode)
        Dim node As MenuNode = New MenuNode
        node.ID = "20"
        node.Text = "Copy (POD)"
        node.ClickAction = eClickAction.None
        parent.DNNNodes.Add(node)
        node = New MenuNode
        node.ID = "21"
        node.Text = "Paste (POD)"
        node.ClickAction = eClickAction.None
        parent.DNNNodes.Add(node)
    End Sub

End Class
